package Enums;

public enum PitchType {
    NONE_PITCHED(0),
    FRESH_PITCH(1),
    REPITCH(2);
    
    private final int type;

    PitchType(final int type) {
        this.type = type;
    }

    public int getType() {
        return type;
    }

    public static PitchType getType(final String type) {
        return getType(Integer.parseInt(type));
    }
    
    public static PitchType getType(final int type) {
        switch (type) {
        case 0:
            return NONE_PITCHED;
        case 1:
            return FRESH_PITCH;
        case 2:
            return REPITCH;
        default:
            throw new EnumConstantNotPresentException(PitchType.class, String.valueOf(type));
        }
    }
    
    public static PitchType getTypeByName(final String str) {
        if(str.equals("NONE_PITCHED")){
            return NONE_PITCHED;
        } else if(str.equals("FRESH_PITCH")){
            return FRESH_PITCH;
        } else if(str.equals("REPITCH")){
            return REPITCH;
        } else {
            return NONE_PITCHED;
        }
    }
}
